package com.ruoyi.web.controller.edh;

import java.util.List;

import com.ruoyi.edh.domain.vo.EdhWithdrawVo;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.edh.domain.EdhWithdraw;
import com.ruoyi.edh.service.IEdhWithdrawService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 易订货-提现审核Controller
 *
 * @author xxx
 * @date 2020-09-21
 */
@RestController
@RequestMapping("/edh/withdraw")
@Api(description = "易订货-提现审核")
public class EdhWithdrawController extends BaseController {
    @Autowired
    private IEdhWithdrawService edhWithdrawService;

    /**
     * 查询易订货-提现审核列表
     */
    @GetMapping("/list")
    @ApiOperation("易订货-提现审核列表")
    public TableDataInfo list(EdhWithdraw edhWithdraw) {
        startPage();
        List<EdhWithdrawVo> list = edhWithdrawService.selectEdhWithdrawList(edhWithdraw);
        return getDataTable(list);
    }

    /**
     * 导出易订货-提现审核列表
     */
    @Log(title = "易订货-提现审核", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    @ApiOperation("导出易订货-提现审核列表")
    public AjaxResult export(EdhWithdraw edhWithdraw) {
        List<EdhWithdrawVo> list = edhWithdrawService.selectEdhWithdrawList(edhWithdraw);
        ExcelUtil<EdhWithdrawVo> util = new ExcelUtil<EdhWithdrawVo>(EdhWithdrawVo.class);
        return util.exportExcel(list, "withdraw");
    }

    /**
     * 获取易订货-提现审核详细信息
     */
    @GetMapping
    @ApiOperation("获取易订货-提现审核详细信息")
    public AjaxResult getInfo(Long id) {
        return AjaxResult.success(edhWithdrawService.selectEdhWithdrawById(id));
    }

    /**
     * 新增易订货-提现审核
     */
    @Log(title = "易订货-提现审核", businessType = BusinessType.INSERT)
    @PostMapping
    @ApiOperation("新增易订货-提现审核")
    public AjaxResult add(@RequestBody EdhWithdraw edhWithdraw) {
        return toAjax(edhWithdrawService.insertEdhWithdraw(edhWithdraw));
    }

    /**
     * 修改易订货-提现审核
     */
    @Log(title = "易订货-提现审核", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation("修改易订货-提现审核")
    public AjaxResult edit(@RequestBody EdhWithdraw edhWithdraw) {
        return toAjax(edhWithdrawService.updateEdhWithdraw(edhWithdraw));
    }

    /**
     * 删除易订货-提现审核
     */
    @Log(title = "易订货-提现审核", businessType = BusinessType.DELETE)
    @DeleteMapping
    @ApiOperation("删除易订货-提现审核")
    public AjaxResult remove(Long[] ids) {
        return toAjax(edhWithdrawService.deleteEdhWithdrawByIds(ids));
    }
}
